package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.KuaidiBean;
import com.lwj.liwanjia.impl.KuaidiView;
import com.lwj.liwanjia.model.KuaidiModel;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/9/26.
 */

public class KuaidiPresenter {
    private KuaidiView kuaidiView;
    private KuaidiModel kuaidiModel;

    public KuaidiPresenter(KuaidiView kuaidiView) {
        this.kuaidiView = kuaidiView;
        kuaidiModel = new KuaidiModel();
    }

    public void getKuaidi() {
        if (kuaidiView != null) {
            kuaidiModel.getKuaidi(new Subscriber<KuaidiBean>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {
                    kuaidiView.showError((Exception) e);
                }

                @Override
                public void onNext(KuaidiBean kuaidiBean) {
                    kuaidiView.getKuaidi(kuaidiBean);

                }
            });
        }
    }
}
